package day10.task;

import java.util.Arrays;
import java.util.Scanner;

public class TaskOne {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数组长度");
        int n = sc.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        work(arr);
        work2(arr);
    }

    public static void work2(int[] arr) {
        String arrString = Arrays.toString(arr);
        System.out.println(arrString);
    }

    public static void work(int[] arr) {
        StringBuilder sb = new StringBuilder("[");
        sb.capacity();
        for (int i = 0; i < arr.length; i++) {
            if (i != arr.length - 1) {
                sb.append("元素").append(arr[i]).append(",");
            } else {
                sb.append("元素").append(arr[i]).append("]");
            }
        }
        System.out.println(sb.toString());
    }
}
